/**
 *                            License
 * THE WORK (AS DEFINED BELOW) IS PROVIDED UNDER THE TERMS OF THIS  
 * CREATIVE COMMONS PUBLIC LICENSE ("CCPL" OR "LICENSE"). 
 * THE WORK IS PROTECTED BY COPYRIGHT AND/OR OTHER APPLICABLE LAW.  
 * ANY USE OF THE WORK OTHER THAN AS AUTHORIZED UNDER THIS LICENSE OR  
 * COPYRIGHT LAW IS PROHIBITED.
 * 
 * BY EXERCISING ANY RIGHTS TO THE WORK PROVIDED HERE, YOU ACCEPT AND  
 * AGREE TO BE BOUND BY THE TERMS OF THIS LICENSE. TO THE EXTENT THIS LICENSE  
 * MAY BE CONSIDERED TO BE A CONTRACT,
 * THE LICENSOR GRANTS YOU THE RIGHTS CONTAINED 
 * HERE IN CONSIDERATION OF YOUR ACCEPTANCE OF SUCH TERMS AND CONDITIONS.
 * 
 */
package lineage.bean;

/**
 * 角色objid(唯一识别编号)分配管理器.
 * <p>
 * 编号从 1~1,000,000 估计不会用完
 * 
 * @version 2014年3月19日下午9:34:46
 * @author jrwz
 */
public final class L1IdFactoryPc extends L1AbstractIdFactory {
    /**
     * 静态初始化器，由JVM来保证线程安全.
     */
    private static class Holder {
        static L1IdFactoryPc instance = new L1IdFactoryPc();
    }

    /**
     * 取得该类的实例.
     */
    public static L1IdFactoryPc getInstance() {
        return Holder.instance;
    }

    private L1IdFactoryPc() {
        super();
    }

    @Override
    protected int getMinId() {
        return 1; // 起始编号
    }

    @Override
    protected String getMsg() {
        return "加载数据库：角色已用objId";
    }

    @Override
    protected String getSql() {
        final StringBuffer sb = new StringBuffer();
        sb.append("SELECT MAX(id)+1 AS NEXTID FROM (");
        sb.append("SELECT `objid` AS `id` FROM `characters`) t");
        return sb.toString();
    }
}
